package com.example.tourism.mapper;


import com.example.tourism.pojo.po.User;
import com.example.tourism.pojo.vo.req.UserInfoReqVo;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    @Insert("insert into users (email,password) values (#{email},#{password}) ")
    int insertUser(@Param("email") String email,@Param("password") String password);

    @Select("select * from users where username=#{username}")
    User findUserByUsername(String username);

    @Select("select * from users where email=#{email}")
    User selectByEmail(String email);

    @Select("select * from users where id=#{id}")
    User selectById(String id);

    @Update("update users set username=#{user.username}, sex=#{user.sex}, birthday=#{user.birthday} where id=#{Id}")
    int updateUserInfo(UserInfoReqVo user, @Param("Id") String Id);

    @Update("update users set avatar=#{avatarUrl} where id=#{id}")
    int updateUserAvatar(String id, String avatarUrl);

    // 修改用户身份
    @Update("update users set role=#{role} where id=#{id}")
    int updateUserRole(String id, String role);

    @Select("select avatar from users where id=#{userId}")
    String selectAvatarById(String userId);
}
